package java0819;

public class ThreadDemo9 {
    public static void main(String[] args) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    //打印当前线程的名字
                    //Thread.currentThread这个静态方法，获取当前线程实例
                    //哪个线程调用的这个方法，就能获取到对应的实例
                    System.out.println(Thread.currentThread().getName());
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        },"hi");
        t.start();
        System.out.println("id:" + t.getId());
        System.out.println("name:" + t.getName());
        System.out.println("state:" + t.getState());
        System.out.println("priority:" + t.getPriority());
        System.out.println("isDaemon:" + t.isDaemon());
        System.out.println("isInterrupted:" + t.isInterrupted());
        System.out.println("isAlive:" + t.isAlive());
    }
}
